﻿using UnityEngine;
using UnityEngine.UI;
using UnityGameFramework.Runtime;
using Michsky.UI.ModernUIPack;

public class MyGF_FirstUIForm : CustomUIForm
{
    private Button m_Btn;
    private NotificationManager m_NotifyPanel;
    private SwitchManager m_Switch;


    protected override void OnInit(object userData)
    {
        base.OnInit(userData);
        m_Btn = transform.Find("Purple").GetComponent<Button>();
        m_NotifyPanel = transform.Find("Sliding Notification").GetComponent<NotificationManager>();
        m_Switch = transform.Find("StandardSwitch").GetComponent<SwitchManager>();

        m_Btn.onClick.AddListener(() =>
        {
            Debug.Log("点击粉红色按钮");
        });
        m_Btn.onClick.AddListener(() =>
        {
            GameEntry.Sound.PlaySound("Hurt");
            Debug.Log("播放声音");
        });

        m_Switch.OnEvents.AddListener(delegate ()
        {
            EnableNotify();
        });
        m_Switch.OffEvents.AddListener(() =>
        {
            DisableNotify();
        });
    }

    protected override void OnOpen(object userData)
    {
        base.OnOpen(userData);

    }


    protected override void OnClose(bool isShutdown, object userData)
    {
        base.OnClose(isShutdown, userData);
    }

    protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
    {
        base.OnUpdate(elapseSeconds, realElapseSeconds);


    }


    private void EnableNotify()
    {
        m_NotifyPanel.OpenNotification();
    }

    private void DisableNotify()
    {
        m_NotifyPanel.CloseNotification();
    }


}
